/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package parser.part.n1;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Patronus
 */
public class Blank {

    public static void main(String[] args) {


        Summ mySumm = new Summ(5);
        mySumm.setArgs(0, 10);
        mySumm.setArgs(1, 13);
        Summ mySumm1 = new Summ(4);
        mySumm1.setArgs(0, 17);
        mySumm1.setArgs(1, 31);



        Summ myFirstSumm = new Summ(3);
        Summ mySecondSumm = new Summ(7);
        Summ mySecondSumm1 = new Summ(2);


        List ls = new ArrayList();                      //lvl 1
        ls.add(myFirstSumm);                            //rule


        List firstParams = new ArrayList();             //list lvl 2
        firstParams.add(mySecondSumm);
            List secondSummParams = new ArrayList();    //List lvl 3
            secondSummParams.add(mySumm);               //rule
            secondSummParams.add(mySumm1);              //rule    
        firstParams.add(secondSummParams);              //add rule list in rule params

        firstParams.add(mySecondSumm1);
            List secondSummParams1 = new ArrayList();   //List
            secondSummParams1.add(mySumm);              //rule  
            secondSummParams1.add(mySumm1);             //rule
        firstParams.add(secondSummParams1);             //add rule list in rule params

        ls.add(firstParams);
        
        Worker wrk = new Worker();
        test(ls, 1);
        System.out.println("FINALY RESULT:" + wrk.justDoIt(ls));

    }

    private static void test(List ls1, int lvl) {
        for (Object o : ls1) {
            System.out.println("lvl:" + lvl + " " + o.getClass().getCanonicalName());
            if (o.getClass().getCanonicalName().indexOf("List") != -1) {
                test((List) o, lvl++);
            }

        }
    }
}